<template>
    <div style="width:90%;margin:0 auto" id="warticle">
        <g-admin></g-admin>
        <el-form ref="form" :model="form">
            <el-form-item label="发布人:">
                <el-col :span="6">
                    <el-input v-model="form.adminName"></el-input>
                </el-col>
            </el-form-item>
            <el-form-item label="发布标题:">
                <el-col :span="6">
                    <el-input v-model="form.title"></el-input>
                </el-col>
            </el-form-item>
            <el-form-item label="点赞量:(默认为0）">
                <el-col :span="6">
                    <el-input v-model="form.goodNum"></el-input>
                </el-col>
            </el-form-item>
            <el-form-item>
                <mavon-editor v-model="form.content" @change="handle"></mavon-editor>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" size="small" @click="submit">发布</el-button>
            </el-form-item>
        </el-form>
        <!-- <article v-html="myhtml"></article> -->
    </div>
</template>

<script>
    //import { getAddRelease } from "@/request/api";
    import GAdmin from '../../components/gadmin/GAdmin';
    import axios from 'axios';
    export default {
        components:{
            GAdmin
        },
        name: "addRelease",
        data() {
            return {
                form: {
                    adminName:'',
                    title: "",
                    content: "",
                    goodNum:""
                },
                // myhtml: "",
                defaultData: "preview",
                timeValue: ""
            };
        },
        created() {},
        mounted(){
            document.querySelector('.tabbar').setAttribute('style','display:none');
            document.querySelector('.gfooter').setAttribute('style','display:none');
        },
        methods: {
            handle(value, render) {
                this.myhtml = render;
                console.log(value, render);
            },
            submit() {
                let url='http://localhost:8080/article/add';
                axios.post(url,this.form).then(
                    res=>{
                        alert("添加成功！");
                        location.reload(true);
                        console.log(res.data);
                    }
                ).catch(err=> {
                    console.log(err);
                })


            }
        }
    };
</script>

<style scoped lang="scss">
    #warticle{
        height: 100%;
        width: 80%;
        margin-left: 10%;
        background-color: #eaffea;
    }

</style>